<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 检查是否每一行每一列都包含全部整数 -->
    <script>
      var check = function (matrix) {
        for (let i = 0; i < matrix.length; i++) {
          // 判断每行是否有重复
          if (matrix[i].length !== [...new Set(matrix[i])].length) {
            return false
          }
          // 判断每列是否有重复
          let arr = []
          for (let j = 0; j < matrix.length; j++) {
            arr.push(matrix[j][i])
          }
          if (arr.length !== [...new Set(arr)].length) {
            return false
          }
        }
        return true
      }
      console.log(
        check([
          [1, 2, 3],
          [3, 1, 2],
          [2, 3, 1]
        ])
      )
    </script>
  </body>
</html>
